package gamagora.game
{
	import Box2D.Common.Math.b2Vec2;
	import Box2D.Dynamics.Contacts.b2Contact;
	import Box2D.Dynamics.b2Body;
	import Box2D.Dynamics.b2ContactListener;
	import Box2D.Dynamics.b2Fixture;
	
	import gamagora.box2d.OSPhysicData;
	
	public class OSContactListener extends b2ContactListener
	{
		private var _dataA:OSPhysicData;
		private var _dataB:OSPhysicData;
		
		public function OSContactListener()
		{
		}
		
		public override function BeginContact(contact:b2Contact):void 
		{
			_dataA = contact.GetFixtureA().GetUserData();
			_dataB = contact.GetFixtureB().GetUserData();
			_dataA.object.onBeginContact(_dataB.object);
			_dataB.object.onBeginContact(_dataA.object);
		}
		
		public override function EndContact(contact:b2Contact):void 
		{
			_dataA = contact.GetFixtureA().GetUserData();
			_dataB = contact.GetFixtureB().GetUserData();
			_dataA.object.onEndContact(_dataB.object);
			_dataB.object.onEndContact(_dataA.object);
		}
	}
}
